package org.springblade.modules.admin.entity;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;

/**
 * 故障工单维修明细
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "blade_maintain_malfunction_history", autoResultMap = true)
public class MaintainMalfunctionHistory extends TenantEntity {
	/**
	 * 计划id
	 */
	@TableField(value = "plan_id")
	private Long planId;

	/**
	 * 点检部件名称集合 多个&&隔开
	 */
	@TableField(value = "part_names")
	private String partNames;

	/**
	 * 点检部件id集合 多个逗号隔开
	 */
	@TableField(value = "part_ids")
	private String partIds;

	/**
	 * 层站结构id集合
	 */
	@TableField(value = "floor_stand_ids")
	private String floorStandIds;

	/**
	 * 层站结构名称集合
	 */
	@TableField(value = "floor_stand_names")
	private String floorStandNames;

	/**
	 * 1-设备检修 2-部件更换
	 */
	@TableField(value = "dispose_type")
	private Integer disposeType;

	/**
	 * 处理结束时间
	 */
	@TableField(value = "dispose_end_date")
	private Date disposeEndDate;

	/**
	 * 处理图片
	 */
	@TableField(value = "dispose_img_url", typeHandler = JacksonTypeHandler.class)
	private List<HashMap<String, String>> disposeImgUrl;

	/**
	 * 处理描述
	 */
	@TableField(value = "dispose_desc")
	private String disposeDesc;

	/**
	 * 用户id
	 */
	@TableField(value = "user_id")
	private Long userId;

	/**
	 * 分组id
	 */
	@TableField(value = "group_id", exist = false)
	private Long groupId;

	/**
	 * 分组id
	 */
	@TableField(exist = false)
	private String userName;

	/**
	 * 维修详情id
	 */
	@TableField(value = "works_id")
	private Long worksId;


	/**
	 * 评分业务id-维修有值
	 */
	@ApiModelProperty("评分业务id-维修,保养有值")
	private Long scoreWorkId;

	/**
	 * 问题原因
	 */
	private String faultReasonKey;
	private String faultReasonName;
	@ApiModelProperty("维修-故障原因ids")
	@TableField(exist = false)
	private List<String> wxFaultIds;

	public void setWxFaultIds(List<String> wxFaultIds) {
		this.wxFaultIds = wxFaultIds;
		if (wxFaultIds != null && wxFaultIds.size() > 0) {
			this.faultReasonKey = String.join(",", wxFaultIds);
		}
	}

	public void setFaultReasonKey(String faultReasonKey) {
		this.faultReasonKey = faultReasonKey;
		if (StrUtil.isNotEmpty(faultReasonKey)) {
			this.wxFaultIds = Arrays.asList(faultReasonKey.split(","));
		}
	}


	/**
	 * 问题责任
	 */
	private String faultReasonWhoKey;
	private String faultReasonWhoName;
	@ApiModelProperty("维修-问题责任ids")
	@TableField(exist = false)
	private List<String> wxTypeIds;

	public void setWxTypeIds(List<String> wxTypeIds) {
		this.wxTypeIds = wxTypeIds;
		if (wxTypeIds != null && wxTypeIds.size() > 0) {
			this.faultReasonWhoKey = String.join(",", wxTypeIds);
		}
	}

	public void setFaultReasonWhoKey(String faultReasonWhoKey) {
		this.faultReasonWhoKey = faultReasonWhoKey;
		if (StrUtil.isNotEmpty(faultReasonWhoKey)) {
			this.wxTypeIds = Arrays.asList(faultReasonWhoKey.split(","));
		}
	}

	/**
	 * 问题分类
	 */
	private Integer faultReasonClassifiedKey;
	private String faultReasonClassifiedName;

	/**
	 * 紧急程度
	 */
	private Integer emerProcType = -1;


	@ApiModelProperty("子工单id")
	private Long childPlanId;

	/**
	 * 操作记录
	 */
	@TableField(exist = false)
	private List<MaintainCheckRecord> recordList;
}
